package com.jinxin.platform.cdfaceacs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinxin.platform.cdfaceacs.mapper.JurenAcsControlSubscribeInfoDao;
import com.jinxin.platform.cdfaceacs.pojo.domains.AcsControlSubscribeInfo;
import com.jinxin.platform.cdfaceacs.service.AcsControlSubscribeInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AcsControlSubscribeInfo)表服务实现类
 *
 * @author cyl
 * @since 2020-04-14 15:59:46
 */
@Service
public class AcsControlSubscribeInfoServiceImpl implements AcsControlSubscribeInfoService {
    @Resource
    private JurenAcsControlSubscribeInfoDao jurenAcsControlSubscribeInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AcsControlSubscribeInfo queryById(String id) {
        return this.jurenAcsControlSubscribeInfoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public PageInfo<AcsControlSubscribeInfo> queryAllByLimit(int offset, int limit) {
        PageHelper.startPage(offset,limit);
        List<AcsControlSubscribeInfo> acsControlSubscribeInfos = jurenAcsControlSubscribeInfoDao.queryAllByLimit(offset,limit);
        PageInfo<AcsControlSubscribeInfo> pageInfo = new PageInfo<>(acsControlSubscribeInfos);
        return pageInfo;
    }

    /**
     * 新增数据
     *
     * @param acsControlSubscribeInfo 实例对象
     * @return 实例对象
     */
    @Override
    public AcsControlSubscribeInfo insert(AcsControlSubscribeInfo acsControlSubscribeInfo) {
        this.jurenAcsControlSubscribeInfoDao.insert(acsControlSubscribeInfo);
        return acsControlSubscribeInfo;
    }

    /**
     * 修改数据
     *
     * @param acsControlSubscribeInfo 实例对象
     * @return 实例对象
     */
    @Override
    public AcsControlSubscribeInfo update(AcsControlSubscribeInfo acsControlSubscribeInfo) {
        this.jurenAcsControlSubscribeInfoDao.update(acsControlSubscribeInfo);
        return this.queryById(acsControlSubscribeInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.jurenAcsControlSubscribeInfoDao.deleteById(id) > 0;
    }
}